package 剑指offer;

/**
 * @Description:
 * @Author: Administrator
 * @Date: 2020-05-04
 */
public class 剪绳子 {
    public static int cutRope(int target) {
        return big(target, 1, 1);
    }

    public static int big(int left, int value, int max) {
        if (left < 2) {
            return value;
        }
        for (int i = 2; i < left; i++) {
            max = Math.max(max, bigNext(left - i, value * i, max));
        }
        return max;
    }
    public static int bigNext(int left, int value, int max) {
        if (left < 2) {
            return value;
        }
        for (int i = 2; i <= left; i++) {
            max = Math.max(max, bigNext(left - i, value * i, max));
        }
        return max;
    }
    public static void main(String[] args) {
        System.out.println(cutRope(8));
    }
}
